package com.hjm.judge.rabbitmq;

import com.hjm.api.domain.JudgeSubmitDTO;
import com.hjm.common.core.constants.RabbitMQConstants;
import com.hjm.common.core.utils.JsonUtils;
import com.hjm.judge.service.IJudgeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


@Slf4j
@Component
public class JudgeConsumer {
    @Autowired
    private IJudgeService judgeService;

    @RabbitListener(queues = RabbitMQConstants.OJ_WORK_QUEUE)
    public void consume(String message) {
        log.info("收到消息为: {}", message);

        judgeService.doJudgeJavaCode(JsonUtils.parseObject(message, JudgeSubmitDTO.class));
    }
}